package xmltomce;

import static org.junit.Assert.*;

import java.io.File;

import org.junit.Test;
import org.w3c.dom.Node;


public class XPathTest {
	private String testDataRoot = "D:\\JavaWorkspace\\MovieCollectorToMce\\testdata\\";

	@Test
	public void testCreateNewXPathWithClonedNode(){
		XPath xpath = new XPath(testDataRoot+"allMovies.xml");
		String xpathQuery = "movieinfo/movielist/movie[title=\"Alpha Dog\"]";
		Node movieNode = xpath.getNode(xpathQuery);
		
		XPath xpathNode = new XPath(movieNode);
		
		int movieId = xpathNode.getNodeIntValue("movie/id");
		assertEquals(9072, movieId);
		
		File dvdFolder = new File(testDataRoot+"dvds\\Alpha Dog");
		Movie movie = new Movie(dvdFolder, xpathNode);
		assertEquals(9072, movie.getXmlId());
		assertEquals("Alpha Dog", movie.getTitle());
		assertEquals("Nick Cassavetes", movie.getDirector());
	}
	
	
	
}
